//
//  YKPushGuide.m
//  百思不得姐
//
//  Created by Eric.Wu on 16/2/29.
//  Copyright © 2016年 Eric.Wu. All rights reserved.
//

#import "YKPushGuide.h"

@implementation YKPushGuide
// 移除蒙版
- (IBAction)buttonclick:(id)sender {
    [self removeFromSuperview];
}

+ (instancetype)guide
{
    YKPushGuide *view = [[[NSBundle mainBundle] loadNibNamed:@"YKPushGuide" owner:nil options:nil]lastObject];
    
    
    return view;
}
+ (void)show
{
//    NSString *
    NSString *key = @"CFBundleShortVersionString";
    
    // 获得当前软件的版本号

    NSString *currentVersion = [NSBundle mainBundle].infoDictionary[key];
    // 获得沙盒中存储的版本号

    NSString *sanboxVersion = [[NSUserDefaults standardUserDefaults] stringForKey:key];
    
    if (![currentVersion isEqualToString:sanboxVersion]) {
        UIWindow *window = [UIApplication sharedApplication].keyWindow;
        
        YKPushGuide *guideView = [YKPushGuide guide];
        guideView.frame = window.bounds;
        [window addSubview:guideView];
        
        // 存储版本号
        [[NSUserDefaults standardUserDefaults] setObject:currentVersion forKey:key];
//        [[NSUserDefaults standardUserDefaults] setObject:currentVersion forKey:key];
//        立即同步存储
        [[NSUserDefaults standardUserDefaults] synchronize];
    }

}

@end
